<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>问卷调查 - 问卷调查系统</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link href="https://cdn.jsdelivr.net/npm/remixicon@3.5.0/fonts/remixicon.css" rel="stylesheet">
    <style>
        /* 自定义滚动条样式 */
        ::-webkit-scrollbar {
            width: 8px;
            height: 8px;
        }
        ::-webkit-scrollbar-track {
            background: #f1f1f1;
            border-radius: 4px;
        }
        ::-webkit-scrollbar-thumb {
            background: #888;
            border-radius: 4px;
        }
        ::-webkit-scrollbar-thumb:hover {
            background: #555;
        }
        /* 问题卡片容器 */
        .question-container {
            height: calc(100vh - 200px);
            overflow-y: auto;
            scroll-snap-type: y mandatory;
        }
        /* 问题卡片 */
        .question-card {
            scroll-snap-align: start;
            min-height: calc(100vh - 200px);
            display: flex;
            flex-direction: column;
            justify-content: center;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- 导航栏 -->
    <nav class="bg-white border-b">
        <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
            <div class="flex justify-between h-16 items-center">
                <div class="flex items-center">
                    <a href="UI.html" class="flex items-center">
                        <i class="ri-arrow-left-line text-2xl text-gray-600 mr-2"></i>
                        <span class="text-xl font-semibold text-gray-800">问卷调查1</span>
                    </a>
                </div>
                <div class="flex items-center space-x-4">
                    <div class="text-sm text-gray-600">
                        已完成 <span class="text-indigo-600 font-medium" id="completedCount">0</span>/10 题
                    </div>
                </div>
            </div>
        </div>
    </nav>

    <!-- 主要内容区 -->
    <div class="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
        <!-- 进度条 -->
        <div class="mb-8">
            <div class="flex justify-between text-sm text-gray-600 mb-2">
                <span>完成进度</span>
                <span id="progressText">0%</span>
            </div>
            <div class="h-2 bg-gray-200 rounded-full overflow-hidden">
                <div class="h-full bg-indigo-600 rounded-full transition-all duration-300" id="progressBar" style="width: 0%"></div>
            </div>
        </div>

        <!-- 问题容器 -->
        <div class="question-container">
            <!-- 姓名输入卡片 -->
            <div class="question-card bg-white rounded-xl shadow-lg overflow-hidden mb-8">
                <div class="p-6">
                    <div class="mb-8">
                        <h2 class="text-2xl font-bold text-gray-800 mb-2">请输入您的姓名</h2>
                        <p class="text-gray-600">姓名为必填项</p>
                    </div>
                    <div class="space-y-4">
                        <input type="text" id="userName" class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500" placeholder="请输入您的姓名">
                        <div id="nameError" class="text-red-500 text-sm hidden">请输入姓名</div>
                    </div>
                </div>
            </div>

            <!-- 问题卡片 -->
            <div class="question-card bg-white rounded-xl shadow-lg overflow-hidden">
                <div class="p-6">
                    <div class="mb-8">
                        <h2 class="text-2xl font-bold text-gray-800 mb-2">1. 您的工作类型是？</h2>
                        <p class="text-gray-600">请选择最符合您情况的选项</p>
                    </div>

                    <div class="space-y-4">
                        <label class="flex items-center p-4 border border-gray-200 rounded-lg cursor-pointer hover:bg-gray-50 transition-colors">
                            <input type="radio" name="q1" class="hidden">
                            <div class="w-6 h-6 border-2 border-gray-300 rounded-full mr-4 flex items-center justify-center">
                                <div class="w-3 h-3 bg-indigo-600 rounded-full hidden"></div>
                            </div>
                            <span class="text-gray-700">全职工作</span>
                        </label>

                        <label class="flex items-center p-4 border border-gray-200 rounded-lg cursor-pointer hover:bg-gray-50 transition-colors">
                            <input type="radio" name="q1" class="hidden">
                            <div class="w-6 h-6 border-2 border-gray-300 rounded-full mr-4 flex items-center justify-center">
                                <div class="w-3 h-3 bg-indigo-600 rounded-full hidden"></div>
                            </div>
                            <span class="text-gray-700">兼职工作</span>
                        </label>

                        <label class="flex items-center p-4 border border-gray-200 rounded-lg cursor-pointer hover:bg-gray-50 transition-colors">
                            <input type="radio" name="q1" class="hidden">
                            <div class="w-6 h-6 border-2 border-gray-300 rounded-full mr-4 flex items-center justify-center">
                                <div class="w-3 h-3 bg-indigo-600 rounded-full hidden"></div>
                            </div>
                            <span class="text-gray-700">自由职业</span>
                        </label>

                        <label class="flex items-center p-4 border border-gray-200 rounded-lg cursor-pointer hover:bg-gray-50 transition-colors">
                            <input type="radio" name="q1" class="hidden">
                            <div class="w-6 h-6 border-2 border-gray-300 rounded-full mr-4 flex items-center justify-center">
                                <div class="w-3 h-3 bg-indigo-600 rounded-full hidden"></div>
                            </div>
                            <span class="text-gray-700">创业</span>
                        </label>
                    </div>
                </div>
            </div>

            <!-- 更多问题卡片... -->
        </div>

        <!-- 提交按钮 -->
        <div class="flex justify-center mt-8">
            <button id="submitBtn" class="px-8 py-3 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700 transition-colors">
                提交问卷
            </button>
        </div>
    </div>

    <script>
        // 问卷数据
        const questions = [
            {
                id: 1,
                question: "您的工作类型是？",
                options: ["全职工作", "兼职工作", "自由职业", "创业"]
            },
            // 添加更多问题...
        ];

        // 选项选择效果
        document.querySelectorAll('input[type="radio"]').forEach(radio => {
            radio.addEventListener('change', function() {
                // 移除所有选中状态
                document.querySelectorAll('.w-3').forEach(dot => {
                    dot.classList.add('hidden');
                });
                // 添加当前选中状态
                this.parentElement.querySelector('.w-3').classList.remove('hidden');
                updateProgress();
            });
        });

        // 更新进度
        function updateProgress() {
            const totalQuestions = document.querySelectorAll('input[type="radio"]').length / 4;
            const answeredQuestions = document.querySelectorAll('input[type="radio"]:checked').length;
            const progress = (answeredQuestions / totalQuestions) * 100;
            
            document.getElementById('completedCount').textContent = answeredQuestions;
            document.getElementById('progressText').textContent = `${Math.round(progress)}%`;
            document.getElementById('progressBar').style.width = `${progress}%`;
        }

        // 提交按钮点击事件
        document.getElementById('submitBtn').addEventListener('click', function() {
            const userName = document.getElementById('userName').value.trim();
            const answeredQuestions = document.querySelectorAll('input[type="radio"]:checked').length;
            const totalQuestions = document.querySelectorAll('input[type="radio"]').length / 4;

            // 验证姓名
            if (!userName) {
                document.getElementById('nameError').classList.remove('hidden');
                return;
            }

            // 验证是否所有题目都已回答
            if (answeredQuestions < totalQuestions) {
                alert('请回答所有问题后再提交');
                return;
            }

            // 提交成功
            alert('问卷提交成功！');
            window.location.href = 'UI.html';
        });

        // 姓名输入框验证
        document.getElementById('userName').addEventListener('input', function() {
            if (this.value.trim()) {
                document.getElementById('nameError').classList.add('hidden');
            }
        });
    </script>
</body>
</html> 